/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package riaxprez;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;

/**
 *
 * @author Vincent
 */
public class ViewAccueil{
    AppModel model;
    private int langue = 1;
    
    /* IHM */
    Stage stage;
    Scene scene;
    
    /* Layout / Panel */
    BorderPane root;
    HBox pnTop;
    VBox pnCenter;
    HBox pnBottom;
    
    /* Labels */
    Label lbTitle;
    
    /* Boutons */
    Button btnNew;
    Button btnOpen;
    
    /* Images */
    Image imgFr = new Image(ViewAccueil.class.getResourceAsStream("francais.png"));
    ImageView imageFr = new ImageView(imgFr);
    Label lbFr = new Label("",imageFr);
    Image imgAng = new Image(ViewAccueil.class.getResourceAsStream("anglais.png"));
    ImageView imageAng = new ImageView(imgAng);
    Label lbAng = new Label("",imageAng);
    Image imgAll = new Image(ViewAccueil.class.getResourceAsStream("allemand.png"));
    ImageView imageAll = new ImageView(imgAll);
    Label lbAll = new Label("",imageAll);
    DropShadow ds = new DropShadow();
    
    public ViewAccueil(AppModel model){
        this.model = model;
        stage = new Stage();
        init(stage);
    }
    
    private void init(Stage stage){
        /* Panel principal */
        root = new BorderPane();
        root.setPrefWidth(450);
        root.setPrefHeight(350);
        
        /* Panel du haut contenant le titre */
        pnTop = new HBox();
        pnTop.setPrefWidth(200);
        pnTop.setPrefHeight(100);
        pnTop.setAlignment(Pos.BOTTOM_CENTER);
        pnTop.setPadding(new Insets(20,20,20,30));
        
        lbTitle = new Label("EIA - PREZ");
        lbTitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 30));
        pnTop.getChildren().add(lbTitle);
        
        /* Panel du centre contenant les boutons ouvrir/creer */
        pnCenter = new VBox(20);
        pnCenter.setPrefWidth(200);
        pnCenter.setPrefHeight(100);
        pnCenter.setAlignment(Pos.CENTER);
        
        btnNew = new Button("Créer un nouveau projet");
        pnCenter.getChildren().add(btnNew);
        
        btnOpen = new Button("Ouvrir un projet");
        pnCenter.getChildren().add(btnOpen);
        
        /* Panel du bas contenant les images pour les langues */
        pnBottom = new HBox(15);
        pnBottom.setPrefSize(200, 100);
        pnBottom.setAlignment(Pos.CENTER);
        
        /* Langue par defaut francais*/
        lbFr.setEffect(ds);
        pnBottom.getChildren().add(lbFr);
        pnBottom.getChildren().add(lbAng);
        pnBottom.getChildren().add(lbAll);
        
        /* Assignation des panels au panel principal */
        root.setTop(pnTop);
        root.setCenter(pnCenter);
        root.setBottom(pnBottom);
        
        /* Assignation du panel principal a la scene */
        scene = new Scene(root, 600, 300);
        stage.setTitle("Accueil");
        stage.setScene(scene);
        stage.show();
    }
    
    public void setLangue(int l){
        this.langue = l;
    }
    
    public int getLangue(){
        return this.langue;
    }
    
    public void updateEffect(int l){
        switch(l){
            case 1:
                lbFr.setEffect(ds);
                lbAng.setEffect(null);
                lbAll.setEffect(null);
                break;
            case 2:
                lbFr.setEffect(null);
                lbAng.setEffect(ds);
                lbAll.setEffect(null);
                break;
            case 3:
                lbFr.setEffect(null);
                lbAng.setEffect(null);
                lbAll.setEffect(ds);
                break;
            default:
                lbFr.setEffect(ds);
                lbAng.setEffect(null);
                lbAll.setEffect(null);
                break;
        }
    }
}
